package Month09.day0910;

public class HomeWork {

    public static void main(String[] args) {
        int[] a = new int[]{1,2,3,4,5};
        int[] b = new int[]{6,7,8,9,10};
        for (int i = 0; i < a.length; i++) {
            int tmp = a[i];
            a[i] = b[i];
            b[i] = tmp;
        }
        System.out.println("打印数组a：");
        for(int x:a){
            System.out.print(x + " ");
        }
        System.out.println();
        System.out.println("打印数组b:");
        for(int x:b){
            System.out.print(x + " ");
        }
    }//给定两个整型数组, 交换两个数组的内容.
    public static void main1(String[] args) {
        int[] a = new int[]{1,2,3,4,5,6,7,8};
        int[] b = new int[a.length];
        int key = 0;
        int left = 0;
        int right = b.length - 1;
        while(left <= right && key < b.length){
            if(a[key] % 2 == 0){
                b[left] = a[key];
                left++;
            }
            if(a[key] %2 != 0){
                b[right] = a[key];
                right--;
            }
            key++;
        }
        for(int x:b){
            System.out.print(x + " ");
        }
    }//给定整型数组, 把所有的偶数放到数组前面, 把所有奇数放到数组后面.
}
